<html>
<head><meta charset="utf-8"><title>Does Cranelift make code run faster than LLVM -O0? · t-compiler · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/index.html">t-compiler</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Does.20Cranelift.20make.20code.20run.20faster.20than.20LLVM.20-O0.3F.html">Does Cranelift make code run faster than LLVM -O0?</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="204297576"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Does%20Cranelift%20make%20code%20run%20faster%20than%20LLVM%20-O0%3F/near/204297576" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lzutao <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Does.20Cranelift.20make.20code.20run.20faster.20than.20LLVM.20-O0.3F.html#204297576">(Jul 18 2020 at 11:49)</a>:</h4>
<p>Does Cranelife make code run faster than LLVM -O0? If yes, it is incredible.<br>
Build faster and run faster.<br>
cc <span class="user-mention" data-user-id="133247">@bjorn3</span></p>



<a name="204298300"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Does%20Cranelift%20make%20code%20run%20faster%20than%20LLVM%20-O0%3F/near/204298300" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Does.20Cranelift.20make.20code.20run.20faster.20than.20LLVM.20-O0.3F.html#204298300">(Jul 18 2020 at 12:13)</a>:</h4>
<p><span class="user-mention" data-user-id="209117">@lzutao</span> Unfortumately not quite yet. If you enable mir inlining and the only optimization that cg_clif has, then yes it can be a bit faster, but otherwise it is about 10-20% slower on one benchmark.</p>



<a name="204298358"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Does%20Cranelift%20make%20code%20run%20faster%20than%20LLVM%20-O0%3F/near/204298358" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Does.20Cranelift.20make.20code.20run.20faster.20than.20LLVM.20-O0.3F.html#204298358">(Jul 18 2020 at 12:15)</a>:</h4>
<p>I haven't benchmarked how much those optimizations slow down compilation, but expect a non-neglectable slowdown. Especially from the cg_clif optimization. I don't know a lot about compiler optimizations.</p>



<a name="204298388"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Does%20Cranelift%20make%20code%20run%20faster%20than%20LLVM%20-O0%3F/near/204298388" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Does.20Cranelift.20make.20code.20run.20faster.20than.20LLVM.20-O0.3F.html#204298388">(Jul 18 2020 at 12:16)</a>:</h4>
<p>is peepmatic the "only" / most prominent work for cranelift optimisations ? (and btw do we have results about the approach already ?) (the move into wasmtime has made keeping up to date with cranelift as a whole a bit tough :)</p>



<a name="204298455"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Does%20Cranelift%20make%20code%20run%20faster%20than%20LLVM%20-O0%3F/near/204298455" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Does.20Cranelift.20make.20code.20run.20faster.20than.20LLVM.20-O0.3F.html#204298455">(Jul 18 2020 at 12:18)</a>:</h4>
<p>Peepmatic is a peephole optimizer. Currently the rules for it are kept in sync with the traditionally built peephole optimizer that Cranelift already had (preopt) It is by far now the only optimization work. For example the new style backends use a new regalloc that reduces spilling.</p>



<a name="204298466"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Does%20Cranelift%20make%20code%20run%20faster%20than%20LLVM%20-O0%3F/near/204298466" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Does.20Cranelift.20make.20code.20run.20faster.20than.20LLVM.20-O0.3F.html#204298466">(Jul 18 2020 at 12:19)</a>:</h4>
<p>I have also spent quite some effort to avoid using the stack and collapse pointer arithmetic instructions together as much as possible in clif emitted by cg_clif.</p>



<a name="204298523"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Does%20Cranelift%20make%20code%20run%20faster%20than%20LLVM%20-O0%3F/near/204298523" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Does.20Cranelift.20make.20code.20run.20faster.20than.20LLVM.20-O0.3F.html#204298523">(Jul 18 2020 at 12:21)</a>:</h4>
<p>yeah I was mostly waiting for the possibility fitzgen mentioned of adding more rules, coming from Souper and Jubi Taneja's cranelift superoptimizer (though that work has maybe been somewhat integrated into the rest of her Souper work)</p>



<a name="204298650"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Does%20Cranelift%20make%20code%20run%20faster%20than%20LLVM%20-O0%3F/near/204298650" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Does.20Cranelift.20make.20code.20run.20faster.20than.20LLVM.20-O0.3F.html#204298650">(Jul 18 2020 at 12:24)</a>:</h4>
<p><span class="user-mention" data-user-id="116113">@lqd</span> <a href="https://github.com/bytecodealliance/wasmtime/issues/1709#issuecomment-660216202">https://github.com/bytecodealliance/wasmtime/issues/1709#issuecomment-660216202</a></p>



<a name="204298658"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Does%20Cranelift%20make%20code%20run%20faster%20than%20LLVM%20-O0%3F/near/204298658" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Does.20Cranelift.20make.20code.20run.20faster.20than.20LLVM.20-O0.3F.html#204298658">(Jul 18 2020 at 12:24)</a>:</h4>
<p>very timely, thanks :)</p>



<a name="204298727"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Does%20Cranelift%20make%20code%20run%20faster%20than%20LLVM%20-O0%3F/near/204298727" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Does.20Cranelift.20make.20code.20run.20faster.20than.20LLVM.20-O0.3F.html#204298727">(Jul 18 2020 at 12:27)</a>:</h4>
<p>it's already super cool that cg_clif can match -O0 combined with mir opts, when cranelift's purpose is more compilation speed than raw perf per se; great job on cg_clif !</p>



<a name="204333809"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Does%20Cranelift%20make%20code%20run%20faster%20than%20LLVM%20-O0%3F/near/204333809" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lzutao <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Does.20Cranelift.20make.20code.20run.20faster.20than.20LLVM.20-O0.3F.html#204333809">(Jul 19 2020 at 05:19)</a>:</h4>
<p>Thank you. Your work is amazing.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>